<template>
  <ex-dialog
    width="1100px"
    class="ex-diolog"
    :title="title"
    :visible="visible"
    @closeDialog="handleClose"
  >	
		<el-table v-loading="loading" :data="customerList" stripe border>
      <el-table-column label="序号" type="index" width="55" align="center" fixed />
      <el-table-column label="订单号" align="center" prop="orderNo" :show-overflow-tooltip="true" width="180" />
      <el-table-column label="姓名" align="center" prop="customerName" :show-overflow-tooltip="true"/>
      <el-table-column label="手机号" align="center" prop="phone" :show-overflow-tooltip="true"/>
      <el-table-column label="兑换CoCo数量" align="center" prop="cocoNum" :show-overflow-tooltip="true"/>
      <el-table-column label="支付椰分" align="center" prop="payNum" :show-overflow-tooltip="true"/>
      <el-table-column label="手续费" align="center" prop="serviceFee" :show-overflow-tooltip="true"/>
      <el-table-column label="兑换时间" align="center" prop="exchangeTime" :show-overflow-tooltip="true"/>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
          @pagination="getList" />
  </ex-dialog>
</template>
<script>
// components
import Loading from '@/components/Loading/index'
// api
import {
  recordList,
} from '@/api/integralOperation/changeConfig'; 

export default {
  components: {
    Loading
  },
  props: {
    visible: Boolean,
    id: String,
  },
  data() {
    
    return {
      loading: false,
      title: '兑换记录',
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        exchangeConfigId: '',
      },
      customerList: [],
    }
  },
  computed: {
   
  },
  created() {
    this.queryParams.exchangeConfigId = this.id
    this.getList()
	},
  methods: {
    //列表
    getList() {
      this.loading = true;
      recordList(this.queryParams).then(response => {
        this.total = response.result.total
        this.customerList = response.result.records
        this.customerList = this.customerList.map(item => {
          // console.log('item',item)
          Object.keys(item).forEach(key => {
            if (item[key] === '') {
              item[key] = '-'
            }
          })
          return item
        })
        
        this.loading = false;
        
      }).finally(()=>{
        this.loading = false;
      })
    },
    
		//取消
    handleClose(formName) {
      this.$emit('update:visible', false)
			// this.$refs[formName].resetFields();
    },
		//确认
		handleConfirm(){
			this.$emit('success', '你好')
		},
    handleSuccess(msg) {
      if (msg === '已拒绝') {
        var type = 'error'
      } else {
        var type = 'success'
      }
      this.$message({
        message: msg,
        type: type,
        duration: 1000,
        onClose: () => {
          this.handleClose()
          this.$emit('success')
        }
      })
    },
  }
}
</script>
<style lang="scss" scoped>
.ex-diolog {
  ::v-deep .ex--dialog--footer {
    border: none !important;
		padding: 0 !important;
  }
	::v-deep .ex--dialog--main {
    padding: 10px 20px !important; 
  }
}
</style>